#include "homework.h"

#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    My_Array my_array;


    // my_array 调用初始化操作
    my_array.init_my_array();

    my_array.add_element(11);
    my_array.add_element(3);
    my_array.add_element(5);
    my_array.add_element(777);
    my_array.add_element(9);
    my_array.add_element(2);
    my_array.add_element(4);
    my_array.add_element(6);
    my_array.add_element(7);
    //my_array.add_element(8);
    my_array.add_element(10);

    cout << "my_array : ";
    my_array.show();



    My_Array ma;


    ma.init_my_array();

    ma.add_element(11);
    ma.add_element(33);
    ma.add_element(55);
    ma.add_element(777);

    cout << "ma       : ";
    ma.show();

    my_array.replace_all(1, 1, ma);
    cout << "after replacing ma at particular pos :";
    my_array.show();

    my_array.remove_all(ma);
    cout << "after removing all the same value with ma :";
    my_array.show();

/*
    my_array.retain_all(ma);
    cout << "only retaining all the same value with ma :";
    my_array.show();
*/


    cout << "max_value : " << my_array.max_value() << endl;
    cout << "min_value : " << my_array.min_value() << endl;
    cout << "avg_value : " << my_array.avg_value() << endl;
    cout << "where is the first position of the value : " << my_array.find(8) << endl;
    cout << "where is the last position of the value : " << my_array.rfind(7) << endl;
    
    my_array.add_element(4,111);
    
    cout << "after adding an ele at particular index :";
    my_array.show();

    my_array.remove(4);
    cout << "after removing an ele at particular index :";
    my_array.show();

    my_array.remove_all(2);
    cout << "after removing all particular ele :";
    my_array.show();

    my_array.remove_all(2,5);
    cout << "after removing all ele from 2 to 5:";
    my_array.show();

    my_array.replace(2,123);
    cout << "after replacing :";
    my_array.show();

    my_array.replace_all(123,321);
    cout << "after replacing all :";
    my_array.show();

    my_array.reveser();
    cout << "after revesering :";
    my_array.show();
    
    cout << "the particular index value is :" << my_array.at(7) << endl;

    my_array.sort_desc();
    cout << "sort in descending order :";
    my_array.show();

    my_array.sort_asc();
    cout << "sort in ascending order :";
    my_array.show();

/*
    if (my_array.size + ma.size <= my_array.capacity)
    {
        cout << "after adding ma :";
        my_array.add_all(ma);
        my_array.show();
    }
    else
    {
        cout << "越界了哥们儿 ！！" << endl;
    }
*/  
/*  
    if (my_array.size + ma.size <= my_array.capacity)
    {
        cout << "after adding ma at particular index :";
        my_array.add_all(2,ma);
        my_array.show();
    }
    else
    {
        cout << "越界了哥们儿 ！！" << endl;
    }
*/

    

    return 0;
}



